package com.project.grenting.service.housing.impl;


import com.project.grenting.dao.housing.HousingDao;
import com.project.grenting.pojo.Customer;
import com.project.grenting.pojo.Housing;
import com.project.grenting.service.housing.HousingService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
public class HousingServiceImpl implements HousingService {

    @Resource
    private HousingDao housingDao ;

    @Override
    public List<Housing> getAllHousings() {
        return housingDao.getAllHousings() ;
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int addHousing(Housing housing) {
        int success = 0 ;

        //先将用户加入用户表中
        housingDao.addHousing(housing) ;
        System.out.println(housing.getId());

        success = 1 ;

        return success ;
    }
}
